<template>
	<div class="spike">
		<header class="spike-top">
			<div class="top-le">
				<div class="top-le-swiper swiper">
					<ol class="swiper-wrapper">
						<li class="swiper-slide" v-for="it in spikeList" :key="it.id">
							<nav class="title-time">
								<strong>限时特惠</strong>
								<label v-html="filtime(it.times)"></label>
							</nav>
							<div class="contain">
								<article>
									<h4>仅限{{it.num}}个</h4>
									<img :src="it.imgURL"/>
									<p>{{it.city}}</p>
								</article>
								<aside>
									<h3>{{it.title}}</h3>
									<p>
										￥<strong>{{it.price}}</strong>起<em>{{it.oldprice}}</em>
									</p>
								</aside>
							</div>
						</li>
					</ol>
				</div>
			</div>
			<div class="top-ri">
				<article>
					<h3>
						新品推荐
						<i class="iconfont">&#xeb1f;</i>
					</h3>
					<aside>
						<h4>{{newsList.title}}</h4>
						<p>
							￥<strong>{{newsList.price}}</strong>起
						</p>
					</aside>
				</article>
				<article>
					<h3>
						爆品线路
						<i class="iconfont">&#xeb1f;</i>
					</h3>
					<aside>
						<h4>{{hotList.title}}</h4>
						<p>
							￥<strong>{{hotList.price}}</strong>起
						</p>
					</aside>
				</article>
			</div>
		</header>
		<ul class="spike-bottom">
			<li>
				<router-link to="/">
					<h3>宝藏小城</h3>
					<p>挖掘小城魅力</p>
				</router-link>
			</li>
			<li>
				<router-link to="/">
					<h3>秋色播报</h3>
					<p>赏秋好去处</p>
				</router-link>
			</li>
			<li>
				<router-link to="/">
					<h3>侠魅榜</h3>
					<p>每月最佳游记</p>
				</router-link>
			</li>
		</ul>
	</div>
</template>

<script>
	import Swiper,{
		Autoplay,
		EffectCoverflow,
		EffectCube,
		Pagination
	} from 'swiper'
	Swiper.use([Autoplay,EffectCoverflow,EffectCube,Pagination])
	export default{
		name:'Spike',
		props:{
			propSpike:{
				type:Object,
				default:function(){
					return {}
				}
			}
		},
		data(){
			return{
				spikeList : [],
				newsList : {},
				hotList : {},
				now:new Date().getTime()
			}
		},
		computed:{
			filtime(){
				return(x)=>{
					if (x<this.now) {
						return `0天<i>0</i>：<i>0</i>：<i>0</i>`
					}
					let d=Math.floor((x-this.now)/(24*60*60*1000))
					let h=Math.floor((x-this.now)/(60*60*1000)%60)
					let m=Math.floor((x-this.now)/(60*1000)%60)
					let s=Math.floor((x-this.now)/1000%60)
					if (h<10) {
						h='0'+h
					}
					if (m<10) {
						m='0'+m
					}
					if (s<10) {
						s='0'+s
					}
					return `${d}天<i>${h}</i>：<i>${m}</i>：<i>${s}</i>`
				}
			}
			
		},
		updated(){
			new Swiper('.top-le-swiper',{
				loop:true,
				observer:true,
				observeParents:true,
			})
			
		},
		watch:{
			now(){
				setInterval(()=>{
					this.now=new Date().getTime()
				},1000)
			},
			propSpike(){
				this.spikeList=this.propSpike.spikeList
				this.newsList=this.propSpike.newsList
				this.hotList=this.propSpike.hotList
			}
		}
	}
</script>

<style scoped>
	a{
		text-decoration: none;
		color: #000000;
	}
	.spike{
		width: 95%;
		height: 7.6rem;
		margin: 0.8rem auto;
	}
	.spike-top {
		width: 100%;
		height: 65%;
		display: flex;
	}
	.spike-top .top-le{
		width: 55%;
		height: 100%;
		background-image: url(../../../assets/img/bg1.png);
		background-repeat: no-repeat;
		background-size: 100% 100%;
	}
	.spike-top .top-le-swiper{
		width: 90%;
		height: 100%;
		margin: 0 auto;
	}
	.spike-top .top-le-swiper ol{
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		
	}
	.spike-top .top-le-swiper ol .title-time{
		line-height: 0.8rem;
		color: white;
		font-size: 0.4rem;
		display: flex;
		
	}
	.top-le-swiper ol .title-time strong{
		font-weight: bold;
	}
	.top-le-swiper ol .title-time label{
		font-size: 0.25rem;
		flex: 1;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.top-le-swiper ol .title-time label :deep(i){
		width: 0.4rem;
		height: 0.4rem;
		border-radius: 0.2rem;
		background: white;
		color: red;
		margin: 0 0.08rem;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.top-le-swiper .contain{
		height: 4rem;
		width: 100%;
		background: white;
		border-radius: 0.2rem;
	}
	.top-le-swiper .contain article{
		position: relative;
		height: 60%;
	}
	.top-le-swiper .contain article img{
		width: 100%;
		height: 100%;
		border-radius: 0.2rem 0 0 0;
	}
	.top-le-swiper .contain article h4{
		position: absolute;
		left: 0;
		top: 0;
		background-image: linear-gradient(#ffe414,#e6c81a);
		padding: 0.08rem 0.15rem;
		/* 左上右上右下左下 */
		border-radius: 0.2rem 0 0.2rem 0;
	}
	.top-le-swiper .contain article p{
		position: absolute;
		left: 0;
		top: 70%;
		background:rgba(0,0,0,0.6);
		color: white;
		padding: 0.1rem 0.25rem;
		border-radius: 0 0.2rem 0.2rem 0;
	}
	.top-le-swiper .contain aside{
		height: 39%;
		border-radius: 0 0 0.2rem 0.2rem;
		padding: 0.1rem;
	}
	.top-le-swiper .contain aside h3{
		font-size: 0.35rem;
		font-weight: bold;
		line-height: 0.4rem;
		height: 0.8rem;
		overflow: hidden;
		/* 一行文字做省略省略号加溢出隐藏加禁止换行 */
		/* 多行文字省略最后一行超过高度，溢出隐藏且用省略号代替 */
	/* 		text-overflow: ellipsis;
		word-spacing: normal; */	
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}
	.top-le-swiper .contain aside p{
		font-size: 0.3rem;
		line-height: 0.8rem;
		color: orange;
		font-weight: bold;
	}
	.top-le-swiper .contain aside p em{
		color: lightslategrey;
		font-size: 0.2rem;
		text-decoration: line-through;
		padding-left: 0.2rem;
	}
	.spike-top .top-ri{
		width: 45%;
		height: 100%;
		background-image: url(../../../assets/img/bg2.png);
		background-repeat: no-repeat;
		background-size: 100% 100%;
	}
	.top-ri article{
		width: 90%;
		margin: 0 auto;
		height: 50%;
	}
	.top-ri article h3{
		font-size: 0.4rem;
		font-weight: bold;
		color: white;
		line-height: 0.8rem;
	}
	.top-ri article aside{
		text-indent: 1em;
		width: 100%;
		background: white;
		border-radius: 0.2rem;
	}
	.top-ri article h4{
		font-size: 0.4rem;
		font-weight: bold;
		line-height: 0.8rem;
	}
	.top-ri article p{
		line-height: 0.5rem;
		color: orange;
		font-size: 0.3rem;
	}
	.top-ri article strong{
		line-height: 0.4rem;
		font-size: 0.4rem;
		font-weight: bold;
	}
	.top-ri article:first-child{
		border-bottom: 0.03rem solid white;
	}
	.spike-bottom{
		width: 100%;
		height: 35%;
		margin-top: 0.3rem;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
	.spike-bottom li{
		width: 32%;
		height: 100%;
		overflow: hidden;
		background-size: 100% 100%;
	}
	.spike-bottom li h3{
		text-indent: 0.8em;
		font-size: 0.35rem;
		font-weight: bold;
		padding: 0.2rem 0;
	}
	.spike-bottom li p{
		font-size: 0.25rem;
		color: gray;
		text-indent: 1em;
	}
	.spike-bottom li:first-child{
		background-image: url(../../../assets/img/bg3.jpg);
		border-radius: 0.3rem 0 0 0.3rem;	
	}
	.spike-bottom li:nth-child(2){
		background-image: url(../../../assets/img/bg4.png);	
	}
	.spike-bottom li:last-child{
		background-image: url(../../../assets/img/bg5.png);
		border-radius: 0 0.3rem 0.3rem 0;
	}
</style>